<?php
class UserIdentity extends CUserIdentity
{
	public function authenticate()
	{
		// print_r($this);exit();
		$admin = User::model()->findByAttributes(array('username' => $this->username));
		// echo "<pre>";
		// print_r($admin[0]->password);
		// echo "</pre>";
		// exit();
		if($admin === null){
			$this->errorCode = self::ERROR_USERNAME_INVALID;
		}else if ($admin->password!==md5($this->password) . md5('xachdo')) {
			// print_r(seft::ERROR_NONE);exit();
			$this->errorCode = self::ERROR_PASSWORD_INVALID;
			// print_r($this->errorCode);exit();
		}
		else
		{
			$this->setState('user',$admin);        
			$this->errorCode=self::ERROR_NONE;
		}
		//return 0: login.
		return $this->errorCode;
	}
}
?>